package com.fcfactory.eggutils.documentUtil.controller;

import com.fcfactory.eggutils.common.RestResponse;
import com.fcfactory.eggutils.documentUtil.service.DocumentUtilService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @autuor 范大晨
 * @Date 2023/9/19 20:03
 * @description 文件处理工具接口
 */
@RestController
@RequestMapping("/documetUtil")
public class DocumentUtilController {

    @Autowired
    private DocumentUtilService documentUtilService;

    /**
     * properties转yml
     *
     * @param propertiesPath    本地properties文件路径
     * @param propertiesCharset properties文件编码
     * @param ymlCharset        yml文件编码
     */
    @PostMapping("/propertiesToYmlUtil")
    public RestResponse propertiesToYml(@RequestParam("propertiesPath") String propertiesPath, @RequestParam(required = false,value = "propertiesPath") String propertiesCharset, @RequestParam(required = false,value = "propertiesPath") String ymlCharset) {
        return documentUtilService.propertiesToYml(propertiesPath, propertiesCharset, ymlCharset);
    }

    @PostMapping("/diffHandle")
    public RestResponse diffHandle(@RequestParam("filePathOriginal") String filePathOriginal, @RequestParam("filePathRevised") String filePathRevised, @RequestParam("droducDirPath") String droducDirPath){
        return documentUtilService.diffHandle(filePathOriginal, filePathRevised, droducDirPath);
    }
}
